﻿{include file="/public/header" /}
<div class="content-wraper full">
    <div class="tools-bar">
        <a data-key="add"><i class="fa fa-plus"></i> 添加</a>
        <a data-key="edit"><i class="fa fa-edit"></i> 编辑</a>
        <a data-key="delete"><i class="fa fa-trash"></i> 删除</a>
    </div>
    <div class="table_box">
        <table class="table_main" id="datalist"></table>
    </div>
</div>
<script type="text/javascript">
Core.Easyui.FieldColumn = [
    {field:'amount',title:'售价(元)',width:120,align:'center'},
];
Core.Easyui.FrozenColumn = [
    {field:'ck',checkbox:true,width:30},
    {field:'id',title:'ID',width:80,align:'center'},
    {field:'vnum',title:'天数',width:320,align:'left',search: true, nowsearch: true, searchtype: 'input'},
];
Core.Easyui.init($("#datalist"), {
    url: "{$_G['_mc_'] ?? ''}/ajax",
    idField: "id",
    fitColumns: false,
    singleSelect : true,
    columns: [Core.Easyui.FieldColumn],
    frozenColumns: [Core.Easyui.FrozenColumn],
    pageSize: 50,
    onDblClickRow: function (index,row){
        Core.Sys.Action('pop',row);
    },
},$(".search_form"));

Core.Sys.Action = function(Tkey,row){
    switch(Tkey){
        case 'add':
            Core.Dialog.open({'title': '添加','width': '500px','height': '320px','url': "{$_G['_mc_'] ?? ''}/edit"});
        break;case 'edit':
            var row = $('#datalist').datagrid('getSelected');if (!row){ Core.Dialog.msg('请选择需要编辑的数据！'); return;}
            Core.Sys.Action('pop',row);
        break;case 'delete':
            var row = $('#datalist').datagrid('getSelected');
            if (!row){Core.Dialog.msg('请选择需要删除的数据！');return;}
		    Core.Dialog.confirm({'title':'删除数据','content':'确认要删除该数据吗？','ok':function(cbk){
				$.get("{$_G['_mc_'] ?? ''}/delete/id/"+row.id+"?r="+Math.random(),function(data){
					$("#datalist").datagrid('reload');cbk();
				});
			}})
        break;case 'pop':
            if (!row) return;
            Core.Dialog.open({'title': '编辑','width': '500px','height': '320px','url': "{$_G['_mc_'] ?? ''}/edit/id/"+row.id});
        break;
    }
    return;
}
/**搜索 */
var Table_Filters = Core.Search.searchArray();
var filterType = Core.Search.typeList();
//var rsourceUrl = "/index/ajax/index"; //搜索字段基础数据
//var regionUrl = "/index/ajax/district/level/"; //城市搜索字段
Core.Search.initFilter("{$_G['_mc_'] ?? ''}/column",null);

$(document).ready(function(){
    $('.tools-bar').find('a[data-key]').on('click',function(){
        var Tkey = $(this).attr('data-key');
        if (!Core.rule('key',Tkey)) return false;
        Core.Sys.Action(Tkey);
    });
});
</script>
{include file="/public/footer" /}